Skip to content

compiler: Suppress incorrect useless_building warning - #11477

Merged
lucioleKi merged 1 commit into
erlang:maintfrom
lucioleKi:isabell/compiler/fix/GH-11472/OTP-20304
Aug 18, 2026
Merged

compiler: Suppress incorrect useless_building warning#11477
lucioleKi merged 1 commit into
erlang:maintfrom
lucioleKi:isabell/compiler/fix/GH-11472/OTP-20304

Conversation

@lucioleKi

Copy link
Copy Markdown
Contributor

Fix #11472

@lucioleKi
lucioleKi requested review from bjorng and jhogberg August 12, 2026 14:14
@lucioleKi lucioleKi self-assigned this Aug 12, 2026
@lucioleKi lucioleKi added the team:VM Assigned to OTP team VM label Aug 12, 2026
@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

CT Test Results

    2 files    335 suites   8m 41s ⏱️
  883 tests   877 ✅ 6 💤 0 ❌
5 756 runs  5 750 ✅ 6 💤 0 ❌

Results for commit e39e930.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@lucioleKi lucioleKi added the testing currently being tested, tag is used by OTP internal CI label Aug 12, 2026
jhogberg
jhogberg previously approved these changes Aug 13, 2026

@bjorng bjorng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the test case to warnings_SUITE in the compiler application, because your fix is not actually in erl_lint.

I will have to think a little bit more about the actual fix.

Comment thread lib/compiler/src/sys_core_fold.erl Outdated
Sub;
descend(Core, #sub{top=true}=Sub) ->
case should_suppress_warning(Core) of
case should_suppress_warning(Core) andalso not is_result_unwanted(Core) of

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By substituting the definition of should_suppress_warning/1 into this expression:

should_suppress_warning(Core) andalso not is_result_unwanted(Core)

we will get:

(is_compiler_generated(Core) orelse is_result_unwanted(Core)) andalso not is_result_unwanted(Core)

which can in turn be simplified to:

is_compiler_generated(Core) andalso not is_result_unwanted(Core)

This says that we remain at the top as long as Core is compiler-generated and the result is wanted. The last part doesn't make much sense. It seems that if Core is compiler-generated we should always stay at the top, regardless of whether the expression is wanted or not. Therefore, I think that the condition should be:

Suggested change
case should_suppress_warning(Core) andalso not is_result_unwanted(Core) of
case is_compiler_generated(Core) of

With this change, your new test case and all the existing test cases in warnings_SUITE still pass.

@lucioleKi
lucioleKi force-pushed the isabell/compiler/fix/GH-11472/OTP-20304 branch from 64edbc0 to e39e930 Compare August 14, 2026 08:19
@lucioleKi
lucioleKi merged commit 7a0217a into erlang:maint Aug 18, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants